package com.starblink.basic.apollo.ext

import com.apollographql.apollo3.api.ApolloResponse
import com.apollographql.apollo3.api.Operation

object ApolloExt {
    /**
     * 如果ApolloResponse（Apollo请求响应）包含指定错误码返回true
     */
    fun <T : Operation.Data> ApolloResponse<T>.findErrorCode(errorCode: String): Boolean {
        if (errors.isNullOrEmpty()) return false
        return errors!!.first().extensions?.get("code") == errorCode
    }
}